package domain.entities;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Compromisopais entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "compromisopais", catalog = "bms")
public class Compromisopais implements java.io.Serializable {

	// Fields

	private Integer id;
	private String country;
	private Set<ProtocoloCompromisopais> protocoloCompromisopaises = new HashSet<ProtocoloCompromisopais>(
			0);
    private Set<Importacion> importaciones = new HashSet<Importacion>(
            0);
    private List<Mail> mails = new ArrayList<Mail>();
    private List<Involucrado> involucrados = new ArrayList<Involucrado>();

    // Constructors

	/** default constructor */
	public Compromisopais() {
	}

	/** minimal constructor */
	public Compromisopais(String country) {
		this.country = country;
	}

    /** minimal constructor */
    public Compromisopais(Integer id, String country) {
        this.country = country;
    }

	/** full constructor */
	public Compromisopais(String country,
			Set<ProtocoloCompromisopais> protocoloCompromisopaises) {
		this.country = country;
		this.protocoloCompromisopaises = protocoloCompromisopaises;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "country", nullable = false)
	public String getCountry() {
		return this.country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "compromisopais")
    @LazyCollection(LazyCollectionOption.FALSE)
	public Set<ProtocoloCompromisopais> getProtocoloCompromisopaises() {
		return this.protocoloCompromisopaises;
	}

	public void setProtocoloCompromisopaises(
			Set<ProtocoloCompromisopais> protocoloCompromisopaises) {
		this.protocoloCompromisopaises = protocoloCompromisopaises;
	}

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "compromisopais")
    @LazyCollection(LazyCollectionOption.FALSE)
    public Set<Importacion> getImportaciones() {
        return this.importaciones;
    }

    public void setImportaciones(Set<Importacion> importaciones) {
        this.importaciones = importaciones;
    }

    public boolean equals(Object obj) {
        Compromisopais otro =  (Compromisopais)obj;
        return this.id.equals(otro.id);
    }

    public int hashCode() {
        return id.hashCode();
    }

    public void addImportacion(Importacion importacion) {
        this.importaciones.add(importacion);
    }

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pais")
    public List<Mail> getMails() {
        return this.mails;
    }

    public void setMails(List<Mail> mails) {
        this.mails = mails;
    }

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "compromisopais")
    public List<Involucrado> getInvolucrados() {
        return this.involucrados;
    }

    public void setInvolucrados(List<Involucrado> involucrados) {
        this.involucrados = involucrados;
    }
}